#include "dialog.h"
#include <QGridLayout>

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
{
    label1 = new QLabel(this);
    label1->setText(tr("radis: "));

    lineEdit = new QLineEdit(this);
    label2 = new QLabel(this);
    button = new QPushButton(this);
    button->setText(tr("area"));

    QGridLayout* mainLayout = new QGridLayout(this);
    mainLayout->addWidget(label1, 0, 0);
    mainLayout->addWidget(lineEdit, 0, 1);
    mainLayout->addWidget(label2, 1, 0);
    mainLayout->addWidget(button, 1, 1);

    connect(button, SIGNAL(clicked(bool)), this, SLOT(showArea()));
    connect(lineEdit, SIGNAL(textChanged(QString)), this, SLOT(showArea()));
}

Dialog::~Dialog()
{

}

void Dialog::showArea()
{
    const static double PI = 3.14;
    const int radius = lineEdit->text().toInt();
    label2->setText(QString().setNum(PI * radius * radius));
}
